package com.neuedu.servlet.employee;



import com.neuedu.service.EmployeeService;
import com.neuedu.service.Imp.EmployeeServiceImp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@WebServlet("/addEmp")
public class AddEmployeeServlet extends HttpServlet {
    private EmployeeService employeeService = new EmployeeServiceImp();
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 告诉浏览器传utf-8编码的数据
        req.setCharacterEncoding("utf-8");

        String account = req.getParameter("account");
        String password = req.getParameter("password");
        String nickname = req.getParameter("nickname");
        String telephone = req.getParameter("telephone");
        String role = req.getParameter("role");
        String isDel = req.getParameter("isDel");
        int i = Integer.parseInt(isDel);

        Integer addEmp = employeeService.addEmp(account,password,nickname,telephone,role,i);
         resp.getWriter().write(addEmp +"");
    }
}
